
#include <iostream>
//#include <Windows.h>
//#include <unistd.h>
#include "newserver.c"
#include "ai.h"
#include "parser.h"

//#include "gameboard.h"


using namespace std;

//int main()
//{
//	Gameboard game;
//	game.setup();
//	char r;
//	char c;
//	short row;
//	short column;
//	bool valid;
//	bool black = true;
//	int ipip=0;
//	cout << "O = White" << endl
//		 << "@ = Black" << endl
//		 << "* = Availble moves" << endl;
//		 
//	game.showNextPos();
//	game.display();
//
//
//	while (true)
//	{
//		Best test1;
//		Best test;
//		while(game.currentColor() == '@')
//		{
//			cout << game.currentColor() << "'s turn" << endl << endl;
//			cout << endl << "AI IS THINKING..." << endl;
//			test.chooseMove(black, 0, game,0,0,5);
//				Sleep(100);
//				game.move((int)test.row,(int)test.column);
//				game.showNextPos();
//				game.display();
//				ipip=test.count_num_moves(game);
//
//			
//		}
//		
//		while(game.currentColor() == 'O')
//		{
//			cout << game.currentColor() << "'s turn" << endl << endl;
//			cout << endl << "AI IS THINKING..." << endl;
//			test1.chooseMove(black, 0, game,0,0,1);
//				Sleep(100);
//				game.move((int)test1.row,(int)test1.column);
//				game.showNextPos();
//				game.display();
//		
//				ipip=ipip+test1.count_num_moves(game);
//		}
//		if(ipip==0)
//			game.gameOver();
//	}	
//}






int main()
{
	server powell_reversii;
	powell_reversii.create_server();
	string input;
	char welcome_msg[BUFSIZ];
	
	parser play;
	play.setupboard();
	// strcpy(welcome_msg,"Reversi\n\n\r");
	powell_reversii.server_send("\n\tABHAY'S AWESOME REVERSII\n\n");
	//strcpy(welcome_msg,"Welcome to Single Client Telnet Server Demo\n\r");
	powell_reversii.server_send("The following commands are acceptable\n");
	powell_reversii.server_send("EXIT | DISPLAY_ON | DISPLAY_OFF | EASY | MEDIUM | HARD|\n");
	powell_reversii.server_send("BLACK | WHITE | UNDO | REDO | SHOW_NEXT_POS\n\n");
	powell_reversii.server_send("Make a move by typing \"move\" followed by row and column.\n");
	powell_reversii.server_send("Example: move 3e \n");
	powell_reversii.server_send("EXIT closes the program\n");
	powell_reversii.server_send("Enter the level of the AI, This can be changed at anytime\n");
	
	input = powell_reversii.server_recv();
	if(input=="easy"||input=="EASY"||input=="medium"||input=="MEDIUM"||input=="hard"||input=="HARD")
		play.expr(input);


	play.displayer();

	powell_reversii.server_send("\nEnter the color you wish to play as, black goes first\n");
	input = powell_reversii.server_recv();
	if(input=="white"||input=="WHITE"||input=="black"||input=="BLACK")
	{
		play.expr(input);
	}
	powell_reversii.server_send("HAVE FUN!!!!\n");
	//play.displayer();

	while(true)
	{
		input = powell_reversii.server_recv();
		play.expr(input);
		
	}
	
	return(0);
}
